package com.xiaoshuidi.cloud.module.report.service.contract;

import com.xiaoshuidi.cloud.module.report.dal.DO.report.ReportContractDayRentDO;
import com.xiaoshuidi.cloud.module.report.dal.DO.report.ReportContractInfoDO;
import com.xiaoshuidi.cloud.module.report.dal.DO.report.ReportOwnerContractDayRentDO;
import com.xiaoshuidi.cloud.module.report.dal.mapper.report.ReportContractDayRentMapper;
import com.xiaoshuidi.cloud.module.report.dal.mapper.report.ReportContractInfoMapper;
import com.xiaoshuidi.cloud.module.report.dal.mapper.report.ReportOwnerContractDayRentMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@RequiredArgsConstructor
@Service
public class ContractOperateServiceImpl implements ContractOperateService{


    private final ReportContractInfoMapper reportContractInfoMapper;
    private final ReportContractDayRentMapper reportContractDayRentMapper;
    private final ReportOwnerContractDayRentMapper reportOwnerContractDayRentMapper;


    @Override
    public long countHaveIncomeContractsByDate(LocalDate startDate, LocalDate endDate) {
       return reportContractInfoMapper.countHaveIncomeContractsByDate(startDate,endDate);
    }

    @Override
    public long countHaveIncomeContractsYesterday(LocalDate yesterday) {
       return reportContractInfoMapper.countHaveIncomeContractsYesterday(yesterday);
    }


    @Override
    public List<ReportContractInfoDO> selectHaveIncomeContractsByDate(LocalDate startDate, LocalDate endDate) {
      return  reportContractInfoMapper.selectHaveIncomeContractsByDate(startDate,endDate);
    }
    @Override
    public List<ReportContractInfoDO> selectHaveIncomeContractsByDateInTurn(LocalDate startDate, LocalDate endDate, Integer from, Integer pageSize) {
      return   reportContractInfoMapper.selectHaveIncomeContractsByDateInTurn(startDate,endDate,from,pageSize);
    }


    @Override
    public List<ReportContractInfoDO> selectHaveIncomeContractsYesterday(LocalDate yesterday) {
      return  reportContractInfoMapper.selectHaveIncomeContractsYesterday(yesterday);
    }
    @Override
    public List<ReportContractInfoDO> selectHaveIncomeContractsYesterdayInTurn(LocalDate yesterday, Integer from, Integer pageSize) {
      return   reportContractInfoMapper.selectHaveIncomeContractsYesterdayInTurn(yesterday,from,pageSize);
    }

    /**
     * 合同信息存库
     */
    @Override
    public void batchSaveContractDayRent(List<ReportContractDayRentDO> reportContractDayRentDOS) {
        reportContractDayRentMapper.insertBatch(reportContractDayRentDOS);
    }
    /**
     * 合同信息存库
     */
    @Override
    public void batchOwnerSaveContractDayRent(List<ReportOwnerContractDayRentDO> ownerContractDayRentDOS) {
        reportOwnerContractDayRentMapper.insertBatch(ownerContractDayRentDOS);
    }

    @Override
    public List<ReportContractDayRentDO> selectListByContractId(Long contractId){
        return reportContractDayRentMapper.selectDayRentList(contractId);
    }
    @Override
    public List<ReportOwnerContractDayRentDO> selectOwnerListByContractId(Long contractId){
        return reportOwnerContractDayRentMapper.selectOwnerListByContractId(contractId);
    }
    @Override
    public ReportContractDayRentDO selectByContratIdAndDays(Long contractId,Integer monthDays){
        return reportContractDayRentMapper.selectByContratIdAndDays(contractId,monthDays);
    }
    @Override
    public ReportOwnerContractDayRentDO selectOwnerByContractIdAndDays(Long contractId,Integer monthDays){
        return reportOwnerContractDayRentMapper.selectOwnerByContractIdAndDays(contractId,monthDays);
    }
}
